package com.uns1066.unsbar.enums;

import java.util.EnumSet;

public enum FileType
{
  FILE_PICTURE(0, "图片文件"), 
  FILE_VIDEO(1, "视频文件"), 
  FILE_AUDIO(2, "音频文件");

  private int code;
  private String description;

  private FileType(int code, String description) { this.code = code;
    this.description = description;
  }

  public int getCode()
  {
    return this.code;
  }
  public void setCode(int code) {
    this.code = code;
  }
  public String getDescription() {
    return this.description;
  }
  public void setDescription(String description) {
    this.description = description;
  }
  public static EnumSet<FileType> allList() {
    EnumSet fileTypeList = EnumSet.allOf(FileType.class);
    return fileTypeList;
  }

  public static String fromCodeToDescription(int code) {
    FileType[] fileTypeList = values();
    for (FileType fileType : fileTypeList) {
      boolean flag = fileType.getCode() == code;
      if (flag) {
        return fileType.getDescription();
      }
    }
    return null;
  }
}